<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>社交网站 - 多样式图文验证组件</title>
  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
  
  <style>
    /* 基础样式 */
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background-color: #f8fafc;
      padding-top: 56px;
      transition: background-color 0.3s;
    }
    
    .container {
      max-width: 540px;
      margin: 0 auto;
      padding: 0 15px;
    }
    
    /* 顶部导航 */
    .main-header {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 56px;
      background-color: white;
      box-shadow: 0 2px 5px rgba(0,0,0,0.05);
      z-index: 1000;
      display: flex;
      align-items: center;
      padding: 0 15px;
    }
    
    .logo {
      font-size: 20px;
      font-weight: 700;
      color: #0d6efd;
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    
    /* 内容区域 */
    .content {
      padding: 20px 0;
    }
    
    .card {
      background-color: white;
      border-radius: 12px;
      padding: 20px;
      margin-bottom: 20px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.05);
      transition: all 0.3s;
    }
    
    .card-title {
      font-size: 18px;
      font-weight: 600;
      margin-bottom: 15px;
      transition: color 0.3s;
    }
    
    /* 验证容器 */
    .verification-container {
      border-radius: 10px;
      overflow: hidden;
      transition: all 0.3s;
      margin-bottom: 20px;
    }
    
    /* 提示文字区域 */
    .verification-prompt {
      padding: 15px;
      font-size: 15px;
      transition: all 0.3s;
    }
    
    .prompt-text {
      margin: 0;
      line-height: 1.5;
    }
    
    /* 图片选择区域 */
    .image-selection {
      padding: 15px;
      transition: all 0.3s;
    }
    
    .selection-title {
      font-size: 14px;
      margin-bottom: 12px;
      font-weight: 500;
      transition: color 0.3s;
    }
    
    .image-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
    }
    
    .image-option {
      border-radius: 8px;
      overflow: hidden;
      position: relative;
      aspect-ratio: 1/1;
      cursor: pointer;
      transition: all 0.2s;
    }
    
    .image-option img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }
    
    .image-option::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0,0,0,0.3);
      opacity: 0;
      transition: opacity 0.2s;
    }
    
    .image-option:hover::after {
      opacity: 1;
    }
    
    .image-option.selected::after {
      opacity: 1;
      background-color: rgba(13, 110, 253, 0.5);
    }
    
    .image-option.selected::before {
      content: '\f00c';
      font-family: 'FontAwesome';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: white;
      font-size: 24px;
      z-index: 10;
    }
    
    /* 按钮样式 */
    .btn {
      padding: 12px;
      border-radius: 8px;
      font-size: 16px;
      font-weight: 500;
      border: none;
      cursor: pointer;
      transition: all 0.3s;
      width: 100%;
    }
    
    .btn-primary {
      background-color: #0d6efd;
      color: white;
    }
    
    .btn-primary:disabled {
      background-color: #93c5fd;
      cursor: not-allowed;
    }
    
    /* 验证结果 */
    .verification-result {
      margin-top: 15px;
      padding: 12px;
      border-radius: 8px;
      font-size: 14px;
      text-align: center;
      display: none;
    }
    
    .result-success {
      background-color: #dcfce7;
      color: #166534;
      display: block;
    }
    
    .result-error {
      background-color: #fee2e2;
      color: #b91c1c;
      display: block;
    }
    
    /* 样式切换器 */
    .style-switcher {
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 1001;
      background-color: white;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
      padding: 10px;
      border: 1px solid #e9ecef;
    }
    
    .switch-label {
      font-size: 13px;
      margin-bottom: 8px;
      display: block;
      font-weight: 500;
    }
    
    .style-options {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    
    .style-btn {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      border: 2px solid transparent;
      cursor: pointer;
      transition: all 0.2s;
    }
    
    .style-btn.active {
      border-color: #0d6efd;
      transform: scale(1.1);
    }
    
    /* 提示框 */
    .toast {
      position: fixed;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      background-color: rgba(0,0,0,0.8);
      color: white;
      border-radius: 8px;
      padding: 10px 15px;
      font-size: 14px;
      z-index: 10000;
      display: none;
    }
    
    /* 样式1 - 经典蓝 */
    .style-1 .verification-container {
      border: 1px solid #e0e7ff;
    }
    
    .style-1 .verification-prompt {
      background-color: #f0f9ff;
      color: #0369a1;
    }
    
    .style-1 .image-selection {
      background-color: white;
    }
    
    .style-1 .selection-title {
      color: #1e40af;
    }
    
    .style-1 .card-title {
      color: #0d6efd;
    }
    
    .style-1 .style-btn:nth-child(1) {
      background-color: #0d6efd;
    }
    
    /* 样式2 - 安全绿 */
    .style-2 .verification-container {
      border: 1px solid #a7f3d0;
    }
    
    .style-2 .verification-prompt {
      background-color: #f0fdf4;
      color: #065f46;
    }
    
    .style-2 .image-selection {
      background-color: white;
    }
    
    .style-2 .selection-title {
      color: #15803d;
    }
    
    .style-2 .btn-primary {
      background-color: #16a34a;
    }
    
    .style-2 .image-option.selected::after {
      background-color: rgba(22, 163, 74, 0.5);
    }
    
    .style-2 .card-title {
      color: #16a34a;
    }
    
    .style-2 .style-btn:nth-child(2) {
      background-color: #16a34a;
    }
    
    /* 样式3 - 深色模式 */
    .style-3 {
      background-color: #0f172a;
    }
    
    .style-3 .main-header {
      background-color: #1e293b;
    }
    
    .style-3 .logo {
      color: #93c5fd;
    }
    
    .style-3 .card {
      background-color: #1e293b;
      color: #f8fafc;
      box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }
    
    .style-3 .verification-container {
      border: 1px solid #334155;
    }
    
    .style-3 .verification-prompt {
      background-color: #1e293b;
      color: #e0f2fe;
    }
    
    .style-3 .image-selection {
      background-color: #0f172a;
    }
    
    .style-3 .selection-title {
      color: #bfdbfe;
    }
    
    .style-3 .btn-primary {
      background-color: #3b82f6;
    }
    
    .style-3 .image-option.selected::after {
      background-color: rgba(59, 130, 246, 0.5);
    }
    
    .style-3 .card-title {
      color: #bfdbfe;
    }
    
    .style-3 .style-switcher {
      background-color: #1e293b;
      border-color: #334155;
    }
    
    .style-3 .switch-label {
      color: #e2e8f0;
    }
    
    .style-3 .style-btn:nth-child(3) {
      background-color: #1e293b;
      border: 1px solid #60a5fa;
    }
    
    /* 样式4 - 简约灰 */
    .style-4 .verification-container {
      border: 1px solid #e2e8f0;
    }
    
    .style-4 .verification-prompt {
      background-color: #f8fafc;
      color: #334155;
    }
    
    .style-4 .image-selection {
      background-color: white;
    }
    
    .style-4 .selection-title {
      color: #334155;
    }
    
    .style-4 .btn-primary {
      background-color: #64748b;
    }
    
    .style-4 .image-option.selected::after {
      background-color: rgba(100, 116, 139, 0.5);
    }
    
    .style-4 .card-title {
      color: #334155;
    }
    
    .style-4 .style-btn:nth-child(4) {
      background-color: #64748b;
    }
    
    /* 样式5 - 高对比 */
    .style-5 .verification-container {
      border: 1px solid #e2e8f0;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }
    
    .style-5 .verification-prompt {
      background-color: #fff7ed;
      color: #c2410c;
      font-weight: 500;
    }
    
    .style-5 .image-selection {
      background-color: white;
    }
    
    .style-5 .selection-title {
      color: #c2410c;
      font-weight: 500;
    }
    
    .style-5 .btn-primary {
      background-color: #ea580c;
    }
    
    .style-5 .image-option.selected::after {
      background-color: rgba(234, 88, 12, 0.5);
    }
    
    .style-5 .card-title {
      color: #c2410c;
    }
    
    .style-5 .style-btn:nth-child(5) {
      background-color: #ea580c;
    }
  </style>
</head>
<body class="style-1">
  <!-- 样式切换器 -->
  <div class="style-switcher">
    <span class="switch-label">选择样式</span>
    <div class="style-options">
      <button class="style-btn active" data-style="1" title="经典蓝"></button>
      <button class="style-btn" data-style="2" title="安全绿"></button>
      <button class="style-btn" data-style="3" title="深色模式"></button>
      <button class="style-btn" data-style="4" title="简约灰"></button>
      <button class="style-btn" data-style="5" title="高对比"></button>
    </div>
  </div>
  
  <!-- 顶部导航 -->
  <header class="main-header">
    <a href="#" class="logo">
      <i class="fa fa-connectdevelop"></i>
      <span>社交圈</span>
    </a>
  </header>
  
  <div class="container">
    <!-- 内容区域 -->
    <div class="content">
      <div class="card">
        <h2 class="card-title">安全验证</h2>
        <p>为了保护您的账号安全，请完成以下验证</p>
        
        <!-- 验证组件 -->
        <div class="verification-container">
          <div class="verification-prompt">
            <p class="prompt-text">
              <i class="fa fa-info-circle"></i> 请选择下图中所有包含<strong>车辆</strong>的图片，完成验证以继续操作
            </p>
          </div>
          
          <div class="image-selection">
            <div class="selection-title">请选择符合要求的图片（可多选）</div>
            
            <div class="image-grid">
              <div class="image-option" data-correct="true">
                <img src="https://picsum.photos/seed/car1/200/200" alt="包含车辆的图片">
              </div>
              <div class="image-option" data-correct="false">
                <img src="https://picsum.photos/seed/flower1/200/200" alt="不包含车辆的图片">
              </div>
              <div class="image-option" data-correct="true">
                <img src="https://picsum.photos/seed/car2/200/200" alt="包含车辆的图片">
              </div>
              <div class="image-option" data-correct="false">
                <img src="https://picsum.photos/seed/tree1/200/200" alt="不包含车辆的图片">
              </div>
              <div class="image-option" data-correct="true">
                <img src="https://picsum.photos/seed/car3/200/200" alt="包含车辆的图片">
              </div>
              <div class="image-option" data-correct="false">
                <img src="https://picsum.photos/seed/building1/200/200" alt="不包含车辆的图片">
              </div>
              <div class="image-option" data-correct="false">
                <img src="https://picsum.photos/seed/animal1/200/200" alt="不包含车辆的图片">
              </div>
              <div class="image-option" data-correct="true">
                <img src="https://picsum.photos/seed/car4/200/200" alt="包含车辆的图片">
              </div>
              <div class="image-option" data-correct="false">
                <img src="https://picsum.photos/seed/food1/200/200" alt="不包含车辆的图片">
              </div>
            </div>
          </div>
        </div>
        
        <button class="btn btn-primary" id="verifyBtn" disabled>验证</button>
        <div class="verification-result" id="resultMessage"></div>
      </div>
      
      <div class="card">
        <h3>为什么需要验证？</h3>
        <p>验证有助于我们区分真实用户和自动化程序，保护您的账号安全和平台环境。每次验证请求都是随机生成的，不会收集您的个人信息。</p>
      </div>
    </div>
  </div>
  
  <!-- 提示框 -->
  <div class="toast" id="toast"></div>
  
  <!-- Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  
  <script>
    // 获取元素
    const verifyBtn = document.getElementById('verifyBtn');
    const resultMessage = document.getElementById('resultMessage');
    const imageOptions = document.querySelectorAll('.image-option');
    const styleBtns = document.querySelectorAll('.style-btn');
    const toast = document.getElementById('toast');
    
    let selectedImages = [];
    const totalCorrect = document.querySelectorAll('[data-correct="true"]').length;
    
    // 图片选择事件
    imageOptions.forEach(option => {
      option.addEventListener('click', function() {
        // 切换选中状态
        this.classList.toggle('selected');
        
        // 更新选中列表
        if (this.classList.contains('selected')) {
          selectedImages.push(this);
        } else {
          selectedImages = selectedImages.filter(item => item !== this);
        }
        
        // 启用/禁用验证按钮
        verifyBtn.disabled = selectedImages.length === 0;
        
        // 重置结果消息
        resultMessage.className = 'verification-result';
      });
    });
    
    // 验证按钮事件
    verifyBtn.addEventListener('click', function() {
      let correctCount = 0;
      let incorrectCount = 0;
      
      // 检查选中的图片
      selectedImages.forEach(img => {
        if (img.getAttribute('data-correct') === 'true') {
          correctCount++;
        } else {
          incorrectCount++;
        }
      });
      
      // 检查未选中的正确图片
      const unselectedCorrect = document.querySelectorAll('[data-correct="true"]:not(.selected)');
      
      // 显示验证结果
      if (correctCount === totalCorrect && incorrectCount === 0 && unselectedCorrect.length === 0) {
        resultMessage.className = 'verification-result result-success';
        resultMessage.textContent = '验证成功！正在为您继续操作...';
        showToast('验证通过');
        
        // 模拟验证成功后的操作
        setTimeout(() => {
          showToast('已完成安全验证');
        }, 1500);
      } else {
        resultMessage.className = 'verification-result result-error';
        resultMessage.textContent = '验证失败，请重新选择所有包含车辆的图片';
        showToast('验证未通过，请重试');
      }
    });
    
    // 切换样式
    styleBtns.forEach(btn => {
      btn.addEventListener('click', function() {
        // 移除所有活跃状态
        styleBtns.forEach(b => b.classList.remove('active'));
        document.body.className = '';
        
        // 添加当前样式
        this.classList.add('active');
        const style = this.getAttribute('data-style');
        document.body.classList.add(`style-${style}`);
        
        // 重置验证状态
        resetVerification();
        
        showToast(`已切换到${this.title}样式`);
      });
    });
    
    // 重置验证状态
    function resetVerification() {
      imageOptions.forEach(option => {
        option.classList.remove('selected');
      });
      selectedImages = [];
      verifyBtn.disabled = true;
      resultMessage.className = 'verification-result';
    }
    
    // 显示提示
    function showToast(message) {
      toast.textContent = message;
      toast.style.display = 'block';
      
      setTimeout(() => {
        toast.style.display = 'none';
      }, 2000);
    }
  </script>
</body>
</html>
